package com.lxy_s_springboot.lxy_s_springboot.controller;


import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;

@RequestMapping("/response")
//@RestController
@Controller
public class ResponseController {
    @RequestMapping("/returnHTMLPage")
    public String returnHTMLPage(){
        return "/hello.html";
    }
    @RequestMapping("/returnData")
    @ResponseBody
    public String returnData(){
        return "data";
    }
    @RequestMapping("/returnHtml")
    @ResponseBody
    public String returnHtml() {
        return "<h1>Hello,HTML~</h1>";
    }
    @RequestMapping("/returnJson")
    @ResponseBody
    public HashMap<String, String> returnJson() {
        HashMap<String, String> map = new HashMap<>();
        map.put("Java", "Java Value");
        map.put("MySQL", "MySQL Value");
        map.put("Redis", "Redis Value");
        return map;
    }
    @RequestMapping(value = "/setStatus")
    @ResponseBody
    public String setStatus(HttpServletResponse response) {
        response.setStatus(401);
        return "设置状态码成功";
    }
}
